import request, {serviceOther} from '@/utils/request'

export function startTask(data) {
  return request({
    url: '/collection/start',
    method: 'post',
    data
  })
}

export function getList(data) {
  return request({
    url: '/collection/list',
    method: 'post',
    data
  })
}

export function download(params, fileName) {
  return serviceOther({
    url: '/collection/export',
    method: 'POST',
    data: params,
    responseType: 'blob'
  }).then( (response) => {
    let blob = response.data;//得到返回数据
    let a = document.createElement('a');//创建a标签
    a.href = (window.URL || window.webkitURL).createObjectURL(new Blob([blob]));//url路径
    a.download = `${fileName ? fileName : '导出数据'}.xlsx`;
    a.click();
  })
}
